/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
	/**
	 * built-in config
	 * @type {Egg.EggAppConfig}
	 **/
	const config = exports = {};
	config.jwt={
		secret:"wekonw"
	};
	// use for cookie sign key, should change to your own and keep security
	config.keys = appInfo.name + '_1657460773348_7362';

	// add your middleware config here
	config.middleware = [];
	/* 数据库配置 */
	config.mysql = {
		// 数据库信息配置
		client: {
			// host
			host: 'localhost',
			// 端口号
			port: '3306',
			// 用户名
			user: 'root',
			// 密码
			password: 'root',
			// 数据库名
			database: 'Weknow',
		},
		// 是否加载到 app 上，默认开启
		app: true,
		// 是否加载到 agent 上，默认关闭
		agent: false,
	};
	/* 开启文件上传 */
	exports.multipart = {
		mode: 'file',
	};
	/* 跨域配置 */
	config.cors = {
		origin: (ctx) => {
			return ctx.request.header.origin
		},
		allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
		credentials: true
	};
	/* 设置session缓存时间 */
	config.session = {
		key: 'EGG_SESS',
		maxAge: 24 * 3600 * 1000 * 15, // 15 天
		httpOnly: true,
		encrypt: true,
	};
	/* 关闭post安全验证 */
	config.security = {
		csrf: {
			enable: false,
			ignoreJSON: true,
		}
	};

	// add your user config here
	const userConfig = {
		// myAppName: 'egg',
	};
	/*  */

	return {
		...config,
		...userConfig,
	};
};
